此时要使得 ab 最小,则要使得 a 最小(a2b=a(ab)),故直接令 a=1 即可得最优答案。
0x02 AC Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include<bits/stdc++.h> usingnamespace std; #define int long long voidsolve(){ int x,y; cin>>x>>y; int ans=x*y/__gcd(x,y)/__gcd(x,y); cout<<1<<" "<<ans<<endl; } signedmain(){ int t; cin>>t; while(t--){ solve(); } return0; }